<?php

class ArrayList
{

  public static function from($data, $labelField, $valueField = 'id')
  {
    $list = array();
    
    if (empty($data)) return $list;
    
    foreach ($data as $row) {
      if (! empty($valueField)) {
        $list[$row->$valueField] = $row->$labelField;
      }
      else {
        $list[] = $row->$labelField;
      }
    }
    
    return $list;
  }

}

?>